﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WPFExcelReport
{
    public partial class YGRABFB : DocumentBase
    {
        VYGRABFB vm;
        #region ==IsGD===========
        public static readonly DependencyProperty IsGDProperty = DependencyProperty.Register("IsGD",
            typeof(bool), typeof(YGRABFB),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsGDChanged));
        public bool IsGD
        {
            get
            {
                return (bool)GetValue(IsGDProperty);
            }
            set
            {
                SetValue(IsGDProperty, value);
            }
        }
        private static void OnIsGDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as YGRABFB;
            if (src != null)
            {
                src.IsGD = (bool)e.NewValue;
            }
        }
        #endregion

        public YGRABFB()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            vm = new VYGRABFB();
            DataContext = vm;
            InitializeComponent();
            this.Name = "复板管理";
            cVK05.IsOrder = true;
            cVK05.IsVV = false;
            if (vm.app.User.Trim() == "ITXV")
            {
                cVK05.KRS = "16";
                cVK05.LFD = "000002";
                cCS.MV.IsMaster = true;
            }
            cVK05.KRS = vm.year.Substring(2, 2);
            cCS.ARTK = "1";
            cVK05.IsCanAdd = false;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return;
                if (IsLoaded)
                    return;
                IsLoaded = true;
                cVK05.IsEdit = true;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void ReSetTab()
        {

        }

        private void AllocationModeCommand(object sender, RoutedEventArgs e)
        {
            object hg;
            if (!IsGD)
            {
                cZoneRV.SetValue(Grid.ColumnProperty, 0);
                cZoneRV.SetValue(Grid.ColumnSpanProperty, 4);
                //ZoneFB.SetValue(Expander.HeightProperty, 700.0);
                ZoneFB.SetValue(Grid.RowProperty, 1);
                ZoneFB.SetValue(Grid.RowSpanProperty, 2);

                IsGD = true;
                ZoneFB.IsExpanded = true;
            }
            else
            {
                IsGD = false;
                ZoneFB.IsExpanded = false;
                //ZoneFB.SetValue(Expander.HeightProperty, 400.0);             
                ZoneFB.SetValue(Grid.RowProperty, 2);
                ZoneFB.SetValue(Grid.RowSpanProperty, 1);
                cZoneRV.SetValue(Grid.ColumnProperty, 2);
                cZoneRV.SetValue(Grid.ColumnSpanProperty, 2);
            }
        } 
    }
}
